package com.teradyne.merlin2.ui.client.views;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.teradyne.merlin2.ui.client.resources.MerlinStyle;

public class WorkListMenuViewImpl extends Composite implements WorkListMenuView {

	private static WorkListMenuViewImplUiBinder uiBinder = GWT.create(WorkListMenuViewImplUiBinder.class);

	interface WorkListMenuViewImplUiBinder extends UiBinder<Widget, WorkListMenuViewImpl> {
	}

	@UiField
	Anchor ancNewRequests;

	@UiField
	Anchor ancActiveRequests;

	@UiField
	Anchor ancClosedRequests;

	@UiField
	Anchor ancApprovedRequests;

	private MerlinStyle merlinStyle;

	private Presenter presenter;

	/**
	 * 
	 * @param merlinStyle
	 *            - inject by gin for ensuring that the Merlin Style was
	 *            initialized
	 */
	@Inject
	public WorkListMenuViewImpl(MerlinStyle merlinStyle) {
		this.merlinStyle = merlinStyle;
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}
	

	@UiHandler("ancNewRequests")
	void onServiceListClicked(ClickEvent event) {
		if (presenter != null) {
			presenter.onNewRequestsClicked();
		}
	}

	@UiHandler("ancActiveRequests")
	void onServiceInstallProblemClicked(ClickEvent event) {
		if (presenter != null) {
			presenter.onActiveRequestsClicked();
		}
	}

	@UiHandler("ancClosedRequests")
	void onAddAddressClicked(ClickEvent event) {
		if (presenter != null) {
			presenter.onClosedRequestsClicked();
		}
	}
	
	@UiHandler("ancApprovedRequests")
	void onChangeAddressClicked(ClickEvent event) {
		if (presenter != null) {
			presenter.onApprovedRequestsClicked();
		}
	}

//	@Override
//	public HasClickHandlers getHandlerNewRequests() {
//		return ancNewRequests;
//	}
//
//	@Override
//	public HasClickHandlers getHandlerActiveRequests() {
//		return ancActiveRequests;
//	}
//
//	@Override
//	public HasClickHandlers getHandlerApprovedRequests() {
//		return ancClosedRequests;
//	}
//
//	@Override
//	public HasClickHandlers getHandlerClosedRequests() {
//		return ancApprovedRequests;
//	}

}
